package com.dragon.shop.utils.exception;

import com.dragon.shop.utils.constants.HttpCode;
import com.dragon.shop.utils.resp.ResponseEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author: Dragon
 * @since: 2023/11/11 10:52
 */
@RestControllerAdvice
public class RestCtrlExceptionHandler {

    private final Logger logger = LoggerFactory.getLogger(RestCtrlExceptionHandler.class);

    public ResponseEntity handleException(Exception e) {
        logger.error("服务器抛出了异常：{}", e);
        return new ResponseEntity(HttpCode.FAILURE, "执行失败", e.getMessage());
    }
}
